﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orange.Logistics.Infrastructure;
using Orange.Logistics.Services;
using Orange.Logistics.Models;
using Newtonsoft.Json;

namespace Orange.Logistics.Controllers {
    public class StoreController : BaseController<Store> {
        //
        // GET: /Store/

        private readonly IStoreService service;

        public StoreController(IStoreService service)
            : base(service) {
            this.service = service;
        }

        protected override Func<Store, object> GetOrderBy(string sort) {
            return c => {
                switch (sort) {
                    case "Names":
                        return c.Names;
                    case "Shortname":
                        return c.Shortname;
                    case "MnCode":
                        return c.Mncode;
                    case "Address":
                        return c.Address;
                    case "Phones":
                        return c.Phones;
                    case "Faxs":
                        return c.Faxs;
                    default:
                        return c.Storeid;
                }
            };
        }

        protected override void Dispose(bool disposing) {
            if (disposing) {
                service.Dispose();
            }
        }
    }
}
